package org.gd.hellojson.gson;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

/**
 * @author Gorhover
 * @version 1.0
 */
public class Test1 {

    public static void main(String...s) {
        String resp = "{\"response\": {\"status\": \"success\", \"action\": \"order_reader\", \"id\": 6936}}";

        JsonParser jsonParser = new JsonParser();
        JsonElement jElement = jsonParser.parse(resp);
        JsonObject jObject = jElement.getAsJsonObject();
        resp = jObject.get("response").toString();
        jObject = jObject.get("response").getAsJsonObject();
        String action = jObject.get("action").getAsString();
        String status = jObject.get("status").getAsString();
        String id = jObject.get("id").getAsString();

        System.out.printf("action: %s\nstatus: %s\nid: %s\n", action, status, id);
    }
}
